<?php
/**
 * Created by PhpStorm.
 * User: BlueIdeaLirui
 * Date: 2019/09/05
 * Time: 17:24
 */

namespace search\controllers\marketDataAnalysis\upgrade;

use business\elasticsearch\services\upgrade\LandProjectService;
use business\elasticsearch\services\upgrade\LandTakeService;
use search\controllers\marketDataAnalysis\BaseController;

class LandController extends BaseController
{
    /**
     * 市场数据-土地数据查询接口
     * @return mixed
     */
    public function actionLandTake()
    {
        try {
            // 项目地区-大数据拓客
            $region    = $this->getParam('region');
            // 拿地开始时间-大数据拓客--拿地数据
            $startDate = $this->getParam('start_date');
            // 拿地结束时间-大数据拓客--拿地数据
            $endDate   = $this->getParam('end_date');
            // 土地用途-大数据拓客--拿地数据
            $landUsage = $this->getParam('land_usage');

            $page      = (int)$this->getParam('page', 'get', '1');
            $pageSize  = (int)$this->getParam('pagesize', 'get', '10');

            if (empty($region)) {
                return $this->error('', '请先选择项目地区');
            }

            return $this->success(
                (new LandTakeService())->getList($region, $startDate, $endDate, $landUsage, $page, $pageSize));
        } catch (\Exception $ex){
            \Yii::error($ex->getMessage());
            return $this->error('', '获取失败，请稍后重试');
        }
    }

    /**
     * 市场数据-项目数据查询接口
     * @return \business\base\models\ResultModel
     */
    public function actionLandProject()
    {
        try {
            // 项目地区-大数据拓客
            $region    = $this->getParam('region');
            // 开盘开始时间-大数据拓客--项目数据
            $startTime = $this->getParam('opening_start_time');
            // 开盘结束时间-大数据拓客--项目数据
            $endTime   = $this->getParam('opening_end_time');
            // 装修状况-大数据拓客--项目数据
            $decorate  = $this->getParam('decorate');

            $page      = (int)$this->getParam('page', 'get', '1');
            $pageSize  = (int)$this->getParam('pagesize', 'get', '10');

            if (empty($region)) {
                return $this->error('', '请先选择项目地区');
            }

            return $this->success(
                (new LandProjectService())->getList($region, $startTime, $endTime, $decorate, $page, $pageSize));
        } catch (\Exception $ex){
            \Yii::error($ex->getMessage());
            return $this->error('', '获取失败，请稍后重试');
        }
    }

    public function actionLandConstruction()
    {
        try {

        } catch (\Exception $ex){
            \Yii::error($ex->getMessage());
            return $this->error('', '获取失败，请稍后重试');
        }
    }
}
